import 'dart:async';

import 'package:aweb5/bean/aplus/common_result_entity.dart';
import 'package:aweb5/bean/aplus/group_plan_list_entity.dart';
import 'package:aweb5/generated/json/common_result_entity_helper.dart';
import 'package:aweb5/generated/json/group_list_entity_helper.dart';
import 'package:aweb5/generated/json/group_plan_list_entity_helper.dart';
import 'package:aweb5/generated/json/has_assist_entity_helper.dart';
import 'package:aweb5/generated/json/task_detail_list_entity_helper.dart';
import 'package:aweb5/providerdata/GroupNoti.dart';
import 'package:flutter/material.dart';
import 'package:aweb5/Para.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:aweb5/custom/dash_painter.dart';
import 'package:aweb5/custom/dashed_rect.dart';
import 'package:expand_widget/expand_widget.dart' as p;
import 'package:configurable_expansion_tile/configurable_expansion_tile.dart';
import 'package:aweb5/custom/bubble_widget.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:bubble/bubble.dart';
//import 'package:fluttertoast/fluttertoast.dart';
import 'package:slide_item/slide_item.dart' as s;
import 'package:aweb5/custom/slide_button_page.dart';
import 'package:photo_view/photo_view.dart';
import 'PhotoViewGalleryScreen.dart';
import 'package:aweb5/util/NaviUtil.dart';

import 'package:aweb5/pages/dash_list.dart';
import 'today_plan_homepage.dart';
import 'package:load/load.dart';
import 'package:aweb5/Constants.dart';
import 'package:aweb5/util/HttpClient.dart';
import 'package:aweb5/util/toast_util.dart';
import 'package:aweb5/config/Config.dart';
import 'package:aweb5/bean/aplus/group_list_entity.dart';
import 'package:aweb5/bean/aplus/task_detail_list_entity.dart';
import 'package:aweb5/style.dart';
import 'package:aweb5/bean/aplus/has_assist_entity.dart';
import 'package:aweb5/pages/unregistry.dart';
import 'package:aweb5/pages/registry_success.dart';
import 'package:aweb5/util/DialogUtil.dart';
import 'package:aweb5/widgetlib/menu_widget.dart';
import 'package:aweb5/pages/choose_mission.dart';
import 'package:provider/provider.dart';
import 'package:progress_dialog/progress_dialog.dart';
import 'package:aweb5/widgetlib/LoadingDialog1.dart';
class Todayplan extends StatefulWidget {
//  GlobalKey<TodayplanState> key;
//  Todayplan(this.key):super(key:key);
  @override
  TodayplanState createState() => TodayplanState();
}

class TodayplanState extends State<Todayplan> with AutomaticKeepAliveClientMixin{
//  List<GlobalKey> key = List();

  List<String> list = List();

//  List<List<GlobalKey>> k = List();

  List<double> heights = List();
  BuildContext context;

  List<String> images = List();

  ///有没有计划无论是自己的，还是follow的
  bool hasPlan = false;
  bool hasFollowOfficialAssist = false;

  String groupId = "";
  List<GroupPlanListDataGroup> groupList = List();
  List<GroupPlanListDataTimeData> dateList = List();
  int selectTab = 0;
  GroupPlanListEntity groupPlanListEntity = null;
  List<GroupPlanListDataTimeDataTaskSend> taskSend = null;
//  GroupPlanListDataMember groupPlanListDataMember = null;

//  String follow = "";

  String date = "";

  List<DropdownMenuItem<String>> sortItems = [];
  String _selectedSort = "";

  int official = 1;

  Widget dashListholder;

  bool get wantKeepAlive => true;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
//    sortItems.add(DropdownMenuItem(value: '排序', child: Text('排序')));
//    sortItems.add(DropdownMenuItem(value: '价格降序', child: Text('价格降序')));
//    sortItems.add(DropdownMenuItem(value: '价格升序', child: Text('价格升序')));



    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {

      requestGroupPlan();

    });


  }



//  void request(){
//
//    requestGroupPlan();
//
//  }



  @override
  void didChangeDependencies() {
    // TODO: implement didChangeDependencies
    super.didChangeDependencies();
    print("change");
  }

  @override
  void didUpdateWidget(Todayplan oldWidget) {
    // TODO: implement didUpdateWidget
    super.didUpdateWidget(oldWidget);
    print("update");
  }
//  ProgressDialog progressDialog ;
  @override
  Widget build(BuildContext context) {
//    progressDialog = ProgressDialog(context,type: ProgressDialogType.Normal, isDismissible: true, showLogs: true);
////
//    progressDialog.style(message: "加载中……",messageTextStyle: TextStyle(color: Colors.black),child: Container(width: ScreenUtil().setWidth(90),height: ScreenUtil().setHeight(90),));
//    progressDialog.style( backgroundColor: Colors.white,message: "加载中……",messageTextStyle: TextStyle(
//        color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600),progressWidget: CircularProgressIndicator(),);

//    progressDialog.style(
////      message: 'Downloading file...',
//      message: "请稍候……",
//      borderRadius: 10.0,
//      backgroundColor: Colors.white,
//      elevation: 10.0,
//      insetAnimCurve: Curves.easeInOut,
//      progress: 0.0,
//      progressWidgetAlignment: Alignment.center,
//      maxProgress: 100.0,
//      progressTextStyle: TextStyle(
//          color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
//      messageTextStyle: TextStyle(
//          color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600),
//    );


    dashListholder = Text("");
    this.context = context;
    return Scaffold(

      backgroundColor: Colors.white,
      appBar: AppBar(
        backgroundColor: Colors.white,
        elevation: 0,
        actions: <Widget>[

        GestureDetector(

          child: Container(
            width: ScreenUtil().setWidth(50),
            height: ScreenUtil().setHeight(50),
            padding: EdgeInsets.all(ScreenUtil().setWidth(10)),
            child: Image.asset("assets/assist/guanbib.png",width: ScreenUtil().setWidth(30),height: ScreenUtil().setHeight(30),),
          ),
          onTap: (){

            NaviUtil.pop(context);

          },
        )

        
      ],),
      body: SafeArea(
        child:
//        ChangeNotifierProvider<GroupNoti>.value(builder:(c){return GroupNoti()},child: Text(""),)

            Column(
          children: <Widget>[
            group(),//群组
            SizedBox(
              height: ScreenUtil().setHeight(8),
            ),
            title(),//标题
            SizedBox(
              height: ScreenUtil().setHeight(8),
            ),
            plan(),//列表
            SizedBox(
              height: ScreenUtil().setHeight(13),
            ),
            Container(
              height: ScreenUtil().setHeight(3),
              color: Color(0xfff9f9f9),
            ),
            planWidget(),//今日计划

            Expanded(child: contentWidget())
//          Expanded(
//            child: level1(),
//          )
          ],
        ),
      ),
    );
  }

  String hasFollowName = "";
  String followUrl ="";
  String followdesc = "";
  Widget contentWidget() {
    if (hasPlan) {
      return DashList(
        taskSend,
        followdata,
        sortItems: sortItems,
        selectedSort: _selectedSort,
        refreshCall: requestGroupPlan,
        groupId: this.groupId,
        edittable: true,

      );
      return Text("");
//      return DashList(taskSend);
    } else {
      //计划首页
      return TodayPlanHomePage(
        hasFollowOfficialAssist,
        sortItems,
        _selectedSort,
        hasFollowName,
        groupList:this.groupList,
        url: followUrl,
        weekday: dateList.length > 0 ? dateList[weekIndex].week : "",
        call: requestGroupPlan,
      );
//    return Text("");
    }
  }
//是否有计划返回不同页面
  Widget planWidget() {
    if (hasPlan) {
      return todayplan();
//      return Text("");
    } else {
      return Text("");
    }
  }

  Widget title() {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        SizedBox(
          width: ScreenUtil().setWidth(14),
        ),
        Text(
          "近期计划",
          style: TextStyle(
              color: Color(0xff101010),
              fontWeight: FontWeight.bold,
              fontSize: ScreenUtil().setSp(20)),
        ),
        SizedBox(
          width: ScreenUtil().setWidth(9),
        ),
        Text(
          "最多显示7天内的计划",
          style: TextStyle(
              color: Color(0xff101010), fontSize: ScreenUtil().setSp(14)),
        ),
      ],
    );
  }

  int weekIndex = 0;
  Widget plan() {
    return Container(
      height: ScreenUtil().setHeight(120),
      child: ListView.builder(
        padding: EdgeInsets.all(0),
        itemBuilder: (c, i) {
          return GestureDetector(
            child: Container(
              height: ScreenUtil().setHeight(120),
              width: ScreenUtil().setWidth(100),
              margin:
                  EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(5)),
              child: Column(
                children: <Widget>[
                  GestureDetector(
                    child: Container(
                      padding: EdgeInsets.only(
                          left: ScreenUtil().setWidth(4),
                          right: ScreenUtil().setWidth(4),
                          top: ScreenUtil().setHeight(4),
                          bottom: ScreenUtil().setHeight(4)),
                      width: ScreenUtil().setWidth(100),
                      height: ScreenUtil().setWidth(28),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: <Widget>[
                          Text(
                            "${dateList[i].week}",
                            style: TextStyle(color: Colors.white),
                          ),
                          Text("${dateList[i].dateMonth}",
                              style: TextStyle(color: Colors.white)),
                        ],
                      ),
                      decoration: BoxDecoration(
                          color: dateList[i].isDefault == 1
                              ? Color(0xffF94F68)
                              : Color(0xffFFAFBB),
                          borderRadius: BorderRadius.only(
                              topLeft: Radius.circular(5),
                              topRight: Radius.circular(5))),
                    ),
                    onTap: () {
                      date = dateList[i].date;
                      weekIndex = i;
                      Constants.weekday = dateList[i].week;
                      requestGroupPlan();
                    },
                  ),
                  plantitle(groupPlanListEntity.data.timeData[i].taskSend, i),
                ],
              ),
            ),
            onTap: () {
              date = dateList[i].date;
              weekIndex = i;
              Constants.weekday = dateList[i].week;
              requestGroupPlan();
            },
          );
        },
        scrollDirection: Axis.horizontal,
        itemCount: dateList.length,
      ),
    );
  }

  Widget plantitle(
      List<GroupPlanListDataTimeDataTaskSend> taskSend, int index) {
    if (taskSend.length == 0) {
      return GestureDetector(
        child: Container(
            width: ScreenUtil().setWidth(100),
            height: ScreenUtil().setWidth(92),
            decoration: BoxDecoration(
                color: Colors.white,
                border: Border.all(
                    color: dateList[index].isDefault == 1
                        ? Color(0xffF94F68)
                        : Color(0xffFFAFBB)),
                borderRadius: BorderRadius.only(
                    bottomLeft: Radius.circular(5),
                    bottomRight: Radius.circular(5))),
            child: GestureDetector(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
//                  Text("+"),
                  SizedBox(
                    height: ScreenUtil().setHeight(10),
                  ),
//                  Text("添加")
                ],
              ),
              onTap: () {
//              NaviUtil.push(
//                  context, ChooseMission(sortItems, sortItems[0].value,this.groupList));
              },
            )),
        onTap: () {
          date = dateList[index].date;
          weekIndex = index;
          requestGroupPlan();
        },
      );
    } else {
      return GestureDetector(
        child: Container(
          width: ScreenUtil().setWidth(100),
          height: ScreenUtil().setWidth(92),
          decoration: BoxDecoration(
              color: Colors.white,
              border: Border.all(
                  color: dateList[index].isDefault == 1
                      ? Color(0xffF94F68)
                      : Color(0xffFFAFBB)),
              borderRadius: BorderRadius.only(
                  bottomLeft: Radius.circular(5),
                  bottomRight: Radius.circular(5))),
//            margin: EdgeInsets.all(1),
          padding: EdgeInsets.only(
            top: ScreenUtil().setHeight(7),
            left: ScreenUtil().setWidth(6),
            right: ScreenUtil().setWidth(6),
          ),
          child: ListView.builder(
            physics: NeverScrollableScrollPhysics(),
            padding: EdgeInsets.all(0),
            itemBuilder: (con, ind) {
              if (ind < 2) {
                return Container(
                  margin: EdgeInsets.symmetric(
                      horizontal: ScreenUtil().setWidth(2),
                      vertical: ScreenUtil().setHeight(1)),
                  width: ScreenUtil().setWidth(89),
                  height: ScreenUtil().setHeight(24),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Expanded(
                        child: Text(
//                        '${dateList[i].taskSend[ind].name}',
                          '${taskSend[ind].name}',
                          style: TextStyle(color: Colors.black),
                          overflow: TextOverflow.ellipsis,
                        ),
                      ),
//                    Image.asset(
//                      "assets/assist/xiala.png",
//                      width: ScreenUtil().setWidth(12),
//                      height: ScreenUtil().setHeight(12),
//                      fit: BoxFit.fill,
//                    )
                    ],
                  ),
                  decoration: BoxDecoration(
                      color: Color(0xffF0F2F5),
                      borderRadius: BorderRadius.circular(3)),
                );
              } else {
                return Container(
                  margin: EdgeInsets.symmetric(
                      horizontal: ScreenUtil().setWidth(2),
                      vertical: ScreenUtil().setHeight(1)),
                  width: ScreenUtil().setWidth(50),
                  height: ScreenUtil().setHeight(24),
                  child: Text("……", style: TextStyle(color: Colors.black)),
                  decoration: BoxDecoration(
                      color: Color(0xffF0F2F5),
                      borderRadius: BorderRadius.circular(3)),
                );
              }
            },
            itemCount: taskSend.length,
          ),
        ),
        onTap: () {
          date = dateList[index].date;
          weekIndex = index;
          requestGroupPlan();
        },
      );
    }
  }

  Widget todayplan() {
    return Container(
        width: ScreenUtil().setWidth(414),
        padding: EdgeInsets.symmetric(
            horizontal: ScreenUtil().setWidth(16),
            vertical: ScreenUtil().setHeight(11)),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            Column(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Row(
                  children: <Widget>[
                    Text(
                      "今日计划",
                      style: TextStyle(
                          color: Color(0xff101010),
                          fontWeight: FontWeight.bold,
                          fontSize: ScreenUtil().setSp(20)),
                    ),
                    SizedBox(
                      width: ScreenUtil().setWidth(6),
                    ),
                    Text(
                      "已跟随${hasFollowName}",
                      style: TextStyle(
                          color: Color(0xff00C91E),
                          fontSize: ScreenUtil().setSp(14)),
                    )
                  ],
                ),
                Text(
                  "最多显示7天内的计划",
                  style: TextStyle(
                    color: Color(0xff101010),
                    fontSize: ScreenUtil().setSp(14),
                  ),
                ),
              ],
            ),
            assistWidget(),
            GestureDetector(
              child: Container(
                width: ScreenUtil().setWidth(87),
                height: ScreenUtil().setHeight(40),
                alignment: Alignment.center,
                decoration: redButtonStyleWithBorder,
                child: Text(
                  "添加任务",
                  style: TextStyle(
                      color: Color(0xffF94F68),
                      fontSize: ScreenUtil().setSp(16)),
                ),
              ),
              onTap: () {
                NaviUtil.push(context,
                    ChooseMission(sortItems, sortItems[0].value, groupList));
              },
            ),
            GestureDetector(
              child: Container(
                width: hasFollowOfficialAssist ? 0 : ScreenUtil().setWidth(87),
                height: ScreenUtil().setHeight(40),
                alignment: Alignment.center,
                decoration: redButtonStyle,
                child: Text(
                  "跟随官方",
                  style: TextStyle(
                      color: Colors.white, fontSize: ScreenUtil().setSp(16)),
                ),
              ),
              onTap: () {
                if(hasFollowName.isEmpty){
                  _showFollowDialog();
                }else{
                  _showChangeFollowDialog();
                }


//                _showChooseGroupDialog();
              },
            )
          ],
        ));
  }


  _showChangeFollowDialog() {
    DialogUtil.showdialog1(
        this.context,
        Container(
          width: ScreenUtil().setWidth(323),
          height: ScreenUtil().setHeight(362),
          decoration: BoxDecoration(
              color: Colors.white, borderRadius: BorderRadius.circular(4)),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              SizedBox(
                height: ScreenUtil().setHeight(24),
              ),
              Text(
                "您是否要更改您的跟随计划",
                style: TextStyle(
                    color: Color(0xff000000),
                    fontSize: ScreenUtil().setSp(16),
                    fontWeight: FontWeight.bold),
              ),
              SizedBox(
                height: ScreenUtil().setHeight(27),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  CircleAvatar(
                    radius: ScreenUtil().setWidth(21.5),
                    backgroundImage: NetworkImage("${followdata.headimgurl}"),
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(12),
                  ),
                  Column(
                    children: <Widget>[
                      Text(

                        "${followdata.name}",
                        style: TextStyle(
                            color: Color(0xff000000),
                            fontSize: ScreenUtil().setSp(18),
                            fontWeight: FontWeight.bold),
                      ),


                    ],
                  )
                ],
              ),
              SizedBox(
                height: ScreenUtil().setHeight(15),
              ),
              Image.asset(
                "assets/assist/change.png",
                width: ScreenUtil().setWidth(44),
                height: ScreenUtil().setHeight(44),
              ),
              SizedBox(
                height: ScreenUtil().setHeight(15),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  CircleAvatar(
                    radius: ScreenUtil().setWidth(21.5),
                    backgroundImage: AssetImage("assets/assist/aplus.png"),
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(12),
                  ),
                  Column(
                    children: <Widget>[
                      Text(
                        "A+官方助理",
                        style: TextStyle(
                            color: Color(0xff000000),
                            fontSize: ScreenUtil().setSp(18),
                            fontWeight: FontWeight.bold),
                      ),
//                      Container(
//                        alignment: Alignment.center,
//                        width: ScreenUtil().setWidth(56),
//                        height: ScreenUtil().setHeight(14),
//                        decoration: redButtonStyle,
//                        child: Text(
//                          "${widget.desc}",
//                          style: TextStyle(
//                              color: Colors.white,
//                              fontSize: ScreenUtil().setSp(10)),
//                        ),
//                      )
                    ],
                  )
                ],
              ),
              SizedBox(
                height: ScreenUtil().setHeight(29),
              ),
              Row(
                children: <Widget>[
                  SizedBox(
                    width: ScreenUtil().setWidth(33),
                  ),
                  GestureDetector(
                    child: Container(
                      width: ScreenUtil().setWidth(119),
                      height: ScreenUtil().setHeight(40),
                      decoration: redButtonStyleWithBorder,
                      alignment: Alignment.center,
                      child: Text(
                        "取消",
                        style: TextStyle(
                            color: Color(0xffF94F68),
                            fontSize: ScreenUtil().setSp(16)),
                      ),
                    ),
                    onTap: () {
                      NaviUtil.pop(context);
                    },
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(15),
                  ),
                  GestureDetector(
                    child: Container(
                      width: ScreenUtil().setWidth(119),
                      height: ScreenUtil().setHeight(40),
                      decoration: redButtonStyle,
                      alignment: Alignment.center,
                      child: Text(
                        "确定",
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: ScreenUtil().setSp(16)),
                      ),
                    ),
                    onTap: () {
                      NaviUtil.pop(context);
                      requetFollow();
                    },
                  ),
                ],
              )
            ],
          ),
        ),
        ScreenUtil().setHeight(362));
  }

  _showFollowDialog() {
    DialogUtil.showdialog1(
        this.context,
        Container(
          width: ScreenUtil().setWidth(323),
          height: ScreenUtil().setHeight(233),
          decoration: BoxDecoration(
              color: Colors.white, borderRadius: BorderRadius.circular(4)),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              SizedBox(
                height: ScreenUtil().setHeight(24),
              ),
              Text(
                "您将永久跟随TA的每日运营计划",
                style: TextStyle(
                    color: Color(0xff000000),
                    fontSize: ScreenUtil().setSp(16),
                    fontWeight: FontWeight.bold),
              ),
              SizedBox(
                height: ScreenUtil().setHeight(24),
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  CircleAvatar(
                    radius: ScreenUtil().setWidth(21.5),
                    backgroundImage: AssetImage("assets/assist/aplus.png"),
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(12),
                  ),
                  Column(
                    children: <Widget>[
                      Text(
                        "A+官方助理",
                        style: TextStyle(
                            color: Color(0xff000000),
                            fontSize: ScreenUtil().setSp(18),
                            fontWeight: FontWeight.bold),
                      ),
//                      Container(
//                        alignment: Alignment.center,
//                        width: ScreenUtil().setWidth(56),
//                        height: ScreenUtil().setHeight(14),
//                        decoration: redButtonStyle,
//                        child: Text(
//                          "${widget.desc}",
//                          style: TextStyle(
//                              color: Colors.white,
//                              fontSize: ScreenUtil().setSp(10)),
//                        ),
//                      )
                    ],
                  )
                ],
              ),
              SizedBox(
                height: ScreenUtil().setHeight(33),
              ),
              Row(
                children: <Widget>[
                  SizedBox(
                    width: ScreenUtil().setWidth(33),
                  ),
                  GestureDetector(
                    child: Container(
                      width: ScreenUtil().setWidth(119),
                      height: ScreenUtil().setHeight(40),
                      decoration: redButtonStyleWithBorder,
                      alignment: Alignment.center,
                      child: Text(
                        "取消",
                        style: TextStyle(
                            color: Color(0xffF94F68),
                            fontSize: ScreenUtil().setSp(16)),
                      ),
                    ),
                    onTap: () {
                      NaviUtil.pop(context);
                    },
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(15),
                  ),
                  GestureDetector(
                    child: Container(
                      width: ScreenUtil().setWidth(119),
                      height: ScreenUtil().setHeight(40),
                      decoration: redButtonStyle,
                      alignment: Alignment.center,
                      child: Text(
                        "确定",
                        style: TextStyle(
                            color: Colors.white,
                            fontSize: ScreenUtil().setSp(16)),
                      ),
                    ),
                    onTap: (){

                      NaviUtil.pop(context);
                      requetFollow();

                    },
                  ),
                ],
              )
            ],
          ),
        ),
        ScreenUtil().setHeight(233));
  }
  Widget assistWidget() {
    if (hasFollowOfficialAssist) {
      return Expanded(
        child: Text(""),
      );
    } else {
      return Text("");
    }
  }

  Widget group() {
    return
      Stack(


        children: <Widget>[
          Container(
            width: ScreenUtil().setWidth(414),
            height: ScreenUtil().setHeight(50),
            child: ListView.builder(
              itemBuilder: (con, ind) {
                return GestureDetector(
                  child:
                  Container(
                    margin: EdgeInsets.only(
                        left: ScreenUtil().setWidth(1),
                        right: ScreenUtil().setWidth(1)),
                    height: ScreenUtil().setHeight(50),
                    padding:
                    EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(5)),
                    alignment: Alignment.center,
                    decoration: groupList[ind].isDefault == 1
                        ? BoxDecoration(
//                  color: selectTab == ind ? Color(0xffF94F68) : Colors.white,
                        color: Color(0xffF94F68),
                        borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(5),
                            topRight: Radius.circular(5)))
                        : BoxDecoration(
//                      color: Colors.white,
                        border: Border(
                            right: BorderSide(
                                color: Color(0xffF94F68),
                                width: ScreenUtil().setHeight(2)),
                            top: BorderSide(color: Color(0xffF94F68),width: ScreenUtil().setHeight(2)),
                            left: BorderSide(color: Color(0xffF94F68),width: ScreenUtil().setHeight(2)),
                            bottom: BorderSide(color: Color(0xffF94F68),width: ScreenUtil().setHeight(2))
                        )
                        ,
                        borderRadius: BorderRadius.circular(ScreenUtil().setHeight(4))
                    ),
                    child: Text(
                      "${groupList[ind].wxGroupName}",
                      style: TextStyle(
                          color: groupList[ind].isDefault == 1
                              ? Colors.white
                              : Color(0xffF94F68),
                          fontSize: ScreenUtil().setSp(18)),
                    ),
                  )

                  ,
                  onTap: () {
                    groupId = groupList[ind].id.toString();
                    Constants.currentGroupId = groupId;
                    requestGroupPlan();
//              selectTab = ind;
//              setState(() {});
                  },
                );
              },
              itemCount: groupList.length,
              scrollDirection: Axis.horizontal,
            ),
          ),
//          Positioned(child: Container(height: ScreenUtil().setHeight(2),width: ScreenUtil().setWidth(414),color: Colors.white,),bottom: 0,)

        ],


      )
      ;
  }

//  String selectGroupID = "";
  GroupPlanListDataFollow followdata = null;

  void dialogCall(String groupid) {
    this.groupId = groupid;
    Constants.currentGroupId = groupId;
  }

//  void _showChooseGroupDialog() {
//    DialogUtil.showdialog1(
//        context,
//        Container(
//          padding: EdgeInsets.symmetric(
//              horizontal: ScreenUtil().setWidth(30),
//              vertical: ScreenUtil().setHeight(30)),
//          width: ScreenUtil().setWidth(329),
//          height: ScreenUtil().setHeight(215),
//          child: Column(
//            crossAxisAlignment: CrossAxisAlignment.start,
//            children: <Widget>[
//              Text(
//                "选择群",
//                style: TextStyle(
//                    color: Color(0xff101010),
//                    fontSize: ScreenUtil().setSp(16),
//                    fontWeight: FontWeight.bold),
//              ),
//              Expanded(child: Text("")),
//              Container(
//                padding: EdgeInsets.only(left: ScreenUtil().setWidth(5)),
//                alignment: Alignment.centerLeft,
//                width: ScreenUtil().setWidth(261),
//                height: ScreenUtil().setHeight(40),
//                decoration: BoxDecoration(
//                    borderRadius:
//                        BorderRadius.circular(ScreenUtil().setWidth(4)),
//                    border: Border.all(color: Color(0xffDCDFE6))),
//                child: MenuWidget(
//                  sortItems,
//                  _selectedSort,
//                  call: dialogCall,
//                ),
//              ),
//              Expanded(child: Text("")),
//              Row(
//                mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                children: <Widget>[
//                  GestureDetector(
//                    child: Container(
//                      alignment: Alignment.center,
//                      width: ScreenUtil().setWidth(119),
//                      height: ScreenUtil().setHeight(40),
//                      child: Text(
//                        "取消",
//                        style: TextStyle(color: Color(0xffF94F68)),
//                      ),
//                      decoration: redButtonStyleWithBorder,
//                    ),
//                    onTap: () {
////                        showdialog = false;
////                        setState(() {
////
////                        });
////                        Overlay.of(context).reassemble();
//                      NaviUtil.pop(context);
//                    },
//                  ),
//                  GestureDetector(
//                    child: Container(
//                      alignment: Alignment.center,
//                      width: ScreenUtil().setWidth(119),
//                      height: ScreenUtil().setHeight(40),
//                      child: Text(
//                        "确定",
//                        style: TextStyle(color: Colors.white),
//                      ),
//                      decoration: redButtonStyle,
//                    ),
//                    onTap: () {
//                      NaviUtil.pop(context);
//                      requetFollow();
//                    },
//                  )
//                ],
//              )
//            ],
//          ),
//          decoration: BoxDecoration(
//              color: Colors.white, borderRadius: BorderRadius.circular(3)),
//        ),
//        ScreenUtil().setHeight(215));
//  }




  void requestGroupPlan() async {
//    light/register/index

  print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>requestgroupplan");
//    var v = await showLoadingDialog();


    DialogUtil.showloadingdialog(context);

    try {
      Map<String, dynamic> map = Map<String, dynamic>();

      map["member_id"] = Constants.memberInfoEntity.data.memberId;
//      map["member_id"] = 124;
      map["group_id"] = groupId;
      map["date"] = date;

      Map<String, dynamic> map1 = await HttpClient.requestLogin(
          Config.requestApi + 'light/group/index',
          data: map);
      print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>${map1.toString()}");
      GroupPlanListEntity loginEntity = new GroupPlanListEntity();

      loginEntity = groupPlanListEntityFromJson(loginEntity, map1);



      DialogUtil.pop(context);

      if (loginEntity.code == null || loginEntity.code != 200) {
//        Fluttertoast.showToast(msg: "null");
        Toast.show(msg: loginEntity.msg);
        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>null");
//        v.dismiss();
        return;
      }
      if (loginEntity.code == 200) {
//        Toast.show(msg: "创建成功");
//        NaviUtil.pop(this.context);
        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>200");
        groupPlanListEntity = loginEntity;
        groupList = loginEntity.data.group;
//        Provider.of<GroupNoti>(this.context).add(groupList);
//        dateList.clear();
//        for(int i=0;i<groupList.length;i++){
//
//          if(groupList[i].isDefault==1){
//            selectGroupID = groupList[i].id.toString();
//          }
//
//        }

        dateList = loginEntity.data.timeData;
        followdata = loginEntity.data.follow;
        hasFollowName = followdata.name;
        followUrl = followdata.headimgurl;
        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>201");
//        taskSend.clear();
        if (dateList.length > 0) {
          taskSend = dateList[weekIndex].taskSend;
          print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>202");
        }
        for(int i=0;i<dateList.length;i++){

          if(dateList[i].isDefault==1){
            Constants.weekday = dateList[i].week;
          }

        }

//        groupPlanListDataMember = loginEntity.data.member;
//        follow = loginEntity.data.member.nickname;
        for (int i = 0; i < loginEntity.data.group.length; i++) {
          sortItems.add(DropdownMenuItem(
              value: loginEntity.data.group[i].wxGroupName.toString(),
              child: Text("${loginEntity.data.group[i].wxGroupName}")));
        }
        if (sortItems.length > 0) {
          _selectedSort = sortItems[0].value;
        }
        print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>203");
//        if(selectGroupID==""){
//          selectGroupID = sortItems[0].value;
//        }

        if (loginEntity.data.follow == null) {
          hasFollowOfficialAssist = false;
          print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>204");
        } else {
          print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>205");
          if (loginEntity.data.follow.isOfficial == 1) {
            hasFollowOfficialAssist = true;
          } else {
            hasFollowOfficialAssist = false;
          }
        }

        for (int i = 0; i < groupList.length; i++) {
          if (groupList[i].isDefault == 1) {
            groupId = groupList[i].id.toString();
            Constants.currentGroupId = groupId;
          }
        }

//        sortItems.add(DropdownMenuItem(value: '排序', child: Text('排序')));
//        if(dateList.length>0){
        if (taskSend.length > 0) {
          print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>206");
          hasPlan = true;
        } else {
          print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>207");
          hasPlan = false;
        }
        setState(() {});
//        v.dismiss();
      }
    } catch (e) {
//      progressDialog.hide();
      DialogUtil.pop(context);
      print(e.toString());
//      v.dismiss();
      print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>${e.toString()}");
    }
  }

//  ///请求群组
//  void requestGroupList() async {
//    var v = await showLoadingDialog();
//    try {
//      Map<String, dynamic> map = Map<String, dynamic>();
//
//      map["member_id"] = Constants.memberInfoEntity.data.memberId;
//
//      Map<String, dynamic> map1 = await HttpClient.requestLogin(
//          Config.requestApi + 'light/group/list',
//          data: map);
//
//      GroupListEntity loginEntity = new GroupListEntity();
//
//      loginEntity = groupListEntityFromJson(loginEntity, map1);
//
//      if (loginEntity.code == null || loginEntity.code != 200) {
////        Fluttertoast.showToast(msg: "null");
//        Toast.show(msg: loginEntity.msg);
//        v.dismiss();
//        return;
//      }
//      if (loginEntity.code == 200) {
////        Toast.show(msg: "创建成功");
////        NaviUtil.pop(this.context);
//        v.dismiss();
//      }
//    } catch (e) {
//      print(e.toString());
//      v.dismiss();
//    }
//  }

  void requetFollow() async {
//    var v = await showLoadingDialog();
//  await progressDialog.show();

     DialogUtil.showloadingdialog(context);

    try {
      Map<String, dynamic> map = Map<String, dynamic>();

      map["member_id"] = Constants.memberInfoEntity.data.memberId;
      map["is_official"] = 1;
      map["follow_id"] = "";
      map["group_id"] = groupId;
      map["is_forever"] = 1;

      Map<String, dynamic> map1 = await HttpClient.requestLogin(
          Config.requestApi + 'light/member/follow',
          data: map);


      CommonResultEntity loginEntity = new CommonResultEntity();

      loginEntity = commonResultEntityFromJson(loginEntity, map1);

       DialogUtil.pop(context);
      if (loginEntity.code == null || loginEntity.code != 200) {
//        Fluttertoast.showToast(msg: "null");
        Toast.show(msg: loginEntity.msg);

        return;
      }
      if (loginEntity.code == 200) {
        Toast.show(msg: "跟随成功");
//        NaviUtil.pop(this.context);
        requestGroupPlan();
      }
    } catch (e) {
      print(e.toString());
      DialogUtil.pop(context);
//      progressDialog.hide();


    }
  }

  ///ind1
  ///
  ///申请运维


}
